﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GNF.GNFService.GNFServer;
using GNF.Geo;

namespace GNF.GNFService.TestHost
{
    public class RandomDataGNFServer : GNFServiceServer
    {


        #region Data generetors
        public static GPSData GenerateTimeData()
        {
            DateTime now = DateTime.Now;
            return new GPSData(now.Hour, now.Minute, now.Second, now.Millisecond);
        }

        public static GPSData GenerateRandomData()
        {
            Random r = new Random();
            return new GPSData(r.Next(100), r.Next(100), r.Next(100), r.Next(1, 10));
        }

        #endregion

        public void Start()
        {
            Connect();

            while (true)
            {
                if (HasSubscribers)
                {
                    PublishGPSData(GenerateTimeData());
                    System.Threading.Thread.Sleep(100);
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
                
            }
        }

    }
}
